package day2.listener;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/day2/listener/test")
public class Test extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("访问了test");

        req.getSession().setAttribute("phone","138");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {}
        req.getSession().removeAttribute("phone");
        req.getServletContext().getAttribute("count");
        resp.getWriter().write("success!");
    }
}
